package org.example.job;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.example.service.TrafficService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @description:
 * @author: 谢超
 * @date: 2024/9/24 11:13
 */
@Component
@Slf4j
public class TrafficJobHandler {

    @Resource
    private TrafficService trafficService;

    /**
     * 过期流量包处理
     * @param param
     * @return
     */
    @XxlJob(value = "TrafficExpiredHandler", init = "init", destroy = "destroy")
    public ReturnT<String> execute(String param) {
        log.info("MyJobHandler execute 任务触发成功，删除过期流量包");
        trafficService.deleteExpireTraffic();
        return ReturnT.SUCCESS;
    }

    private void init() {
        log.info("MyJobHandler init ===");
    }

    private void destroy() {
        log.info("MyJobHandler destroy ===");
    }
}
